{% extends 'base.html' %}
{% load mytags %}
{% load static %}

{% block title %}
    <title>首页</title>
{% endblock %}

{% block content %}
    <div class="m-container m-padded-tb-big">
        <div class="ui container">
            <div class="ui stackable grid">
                <!--左边博客列表-->
                <div class="eleven wide column">
                    <!--header-->
                    <div class="ui top attached segment">
                        <div class="ui middle aligned two column grid">
                            <div class="column">
                                <h3 class="ui teal header">博客</h3>
                            </div>
                            <div class="right aligned column">
                                共 <h2 class="ui orange header m-inline-block m-text-thin"> {% count_blog %} </h2> 篇
                            </div>
                        </div>
                    </div>

                    <!--content-->
                    <div class="ui attached  segment">
                        {# 这里引导用的对象为分页后的对象 #}
                        {% for blog in page_obj.object_list %}
                            <div class="ui padded vertical segment m-padded-tb-large">
                                <div class="ui mobile reversed stackable grid">
                                    <div class="eleven wide column">
                                        <a href="{{ blog.get_absolute_url }}"><h3
                                                class="ui header">{{ blog.title }}</h3></a>
                                        <p class="m-text">{{ blog.desc }}</p>
                                        <div class="ui grid">
                                            <div class="eleven wide column">
                                                <div class="ui mini horizontal link list">
                                                    <div class="item">
                                                        <img src="https://avatars.githubusercontent.com/u/23349356"
                                                             alt=""
                                                             class="ui avatar image">
                                                        <div class="content"><a href="{% url 'blog:about_us' %}"
                                                                                class="header">{{ blog.author.get_full_name }}</a>
                                                        </div>
                                                    </div>
                                                    <div class="item">
                                                        <i class="calendar icon"></i> {{ blog.created }}
                                                    </div>
                                                    <div class="item">
                                                        <i class="eye icon"></i> {{ blog.total_views }}
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="right aligned five wide column">
                                                <a href="{% url 'blog:type_detail' blog.category.id %}" target="_blank"
                                                   class="ui teal basic label m-padded-tiny m-text-thin">{{ blog.category }}</a>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="five wide column">
                                        <a href="#" target="_blank">
                                            <img src="{{ blog.image.url }}" alt=""
                                                 class="ui rounded image">
                                        </a>
                                    </div>
                                </div>
                            </div>
                        {% endfor %}
                    </div>


                    <!--footer-->
                    {# 这里引导用的对象为分页后的对象 #}
                    {% include 'page.html' %}
{#                    <div class="ui bottom attached segment">#}
{#                        <div class="ui middle aligned two column grid">#}
{#                            {% if page_obj.has_previous %}#}
{#                                <div class="column">#}
{#                                    <a href="?page={{ page_obj.previous_page_number }}"#}
{#                                       class="ui mini teal basic button">上一页</a>#}
{#                                </div>#}
{#                            {% else %}#}
{#                                <div class="column">#}
{#                                    <a class="ui mini teal basic button disabled">上一页</a>#}
{#                                </div>#}
{#                            {% endif %}#}
{##}
{#                            {% if page_obj.has_next %}#}
{#                                <div class="right aligned column">#}
{#                                    <a href="?page={{ page_obj.next_page_number }}" class="ui mini teal basic button">下一页</a>#}
{#                                </div>#}
{#                            {% else %}#}
{#                                <div class="right aligned column">#}
{#                                    <a class="ui mini teal basic button disabled">下一页</a>#}
{#                                </div>#}
{#                            {% endif %}#}
{#                        </div>#}
{#                    </div>#}

                </div>

                <!--右边的top-->
                <div class="five wide column">
                    <!--分类-->
                    <div class="ui segments">
                        <div class="ui secondary segment">
                            <div class="ui two column grid">
                                <div class="column">
                                    <i class="idea icon"></i>分类
                                </div>
                                <div class="right aligned column">
                                    <a href="{% url 'blog:types' %}" target="_blank">more <i
                                            class="angle double right icon"></i></a>
                                </div>
                            </div>
                        </div>
                        {% show_categories %}
                    </div>

                    <!--标签-->
                    <div class="ui segments m-margin-top-large">
                        <div class="ui secondary segment">
                            <div class="ui two column grid">
                                <div class="column">
                                    <i class="tags icon"></i>标签
                                </div>
                                <div class="right aligned column">
                                    <a href="{% url 'blog:tags' %}" target="_blank">more <i
                                            class="angle double right icon"></i></a>
                                </div>
                            </div>
                        </div>
                        {% show_tags %}
                    </div>

                    <!--最新推荐-->
                    {% show_recent_posts %}

                    <!--二维码-->
                    <h4 class="ui horizontal divider header m-margin-top-large">扫码关注我</h4>
                    <div class="ui centered card" style="width: 11em">
                        <img src="{% static 'images/wechat.png' %}" alt="" class="ui rounded image">
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

<br>
<br>

{% block javascript %}
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
    <script>
        $('.menu.toggle').click(function () {
            $('.m-item').toggleClass('m-mobile-hide');
        });
    </script>
{% endblock %}
